package com.ss.android.action.b;

import android.view.View;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ListView;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;

public abstract class BaseDetailAdapter extends BaseAdapter implements AbsListView.RecyclerListener, a {
    public boolean a;
    public b b;
    public WeakReference<ListView> mListViewRef;
    private boolean d;

    public BaseDetailAdapter() {

        this.a = true;
        this.d = true;
    }

    public final void a(AbsListView listView) {
        WeakReference v0;
        if (listView != null) {
            v0 = new WeakReference(listView);
            this.mListViewRef = v0;
        } else {
            v0 = null;
        }

        this.mListViewRef = v0;
    }

    public final void a(FeedViewHolder feedViewHolder) {
        this.g();
        if (this.b != null && feedViewHolder != null) {
            this.b.a(feedViewHolder);
            this.d = false;
        }
    }

    public boolean a() {
        return this.a;
    }

    public boolean a(int arg2, FeedViewHolder arg3) {
        return this.a;
    }

    public final List b() {
        List v0;
        Object v1 = null;
        AbsListView v4 = this.c();
        if (v4 == null) {
            v0 = ((List) v1);
        } else {
            ArrayList v2 = new ArrayList();
            int v5 = v4.getChildCount();
            int v3;
            for (v3 = 0; v3 < v5; ++v3) {
                Object v0_1 = v4.getChildAt(v3).getTag();
                if (!(v0_1 instanceof FeedViewHolder)) {
                    v0_1 = v1;
                }

                if (v0_1 != null) {
                    ((List) v2).add(v0_1);
                }
            }

            v0 = v2;
        }

        return v0;
    }

    public final void b(FeedViewHolder arg2) {
        this.g();
        if (this.b != null && arg2 != null) {
            this.b.b(arg2);
        }
    }

    public final AbsListView c() {
        AbsListView v0_1;
        if (this.mListViewRef != null) {
            v0_1 = (AbsListView) this.mListViewRef.get();
        } else {
            v0_1 = null;
        }

        return v0_1;
    }

    public b d() {
        return this.b;
    }

    public final void f() {
        if (!this.d) {
            this.g();
            if (this.b != null) {
                this.b.b(((a) this));
                this.d = true;
            }
        }
    }

    private void g() {
        if (this.b == null) {
            this.b = this.d();
        }
    }

    public final void g_() {
        this.g();
        if (this.b != null) {
            this.b.a(((a) this));
            this.d = false;
        }
    }

    public void onMovedToScrapHeap(View arg3) {
        Object v0 = arg3 != null ? arg3.getTag() : null;
        if ((v0 instanceof FeedViewHolder)) {
            this.b(((FeedViewHolder) v0));
            ((FeedViewHolder) v0).a();
        }
    }
}

